package com.centerm.demo;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.centerm.bluetooth.lkl.demo.R;

/**
 * Created by linwenhui on 2017/5/17.
 */

public class MessageDialog extends Dialog implements View.OnClickListener {

    private TextView txtMsg;
    private ISureListener sureListener;

    public MessageDialog(@NonNull Context context) {
        super(context, R.style.DialogStyle);
        setContentView(R.layout.dialog_message);
        txtMsg = (TextView) findViewById(R.id.txtMsg);
        findViewById(R.id.btnCancel).setOnClickListener(this);
        findViewById(R.id.btnSure).setOnClickListener(this);
    }

    public void setMessage(String message) {
        txtMsg.setText(message);
    }

    public void setSureListener(ISureListener sureListener) {
        this.sureListener = sureListener;
    }

    @Override
    public void onClick(View v) {
        dismiss();
        if (v.getId() == R.id.btnSure && sureListener != null)
            sureListener.onSure();
    }

    public interface ISureListener {
        void onSure();
    }
}
